package net.neiquan.applibrary.adpter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

import net.neiquan.applibrary.utils.ImageUtil;

import java.util.List;

/**
 *  @author miss
 */
public class NoticeLocalPagerAdapter extends PagerAdapter {
	private Context context;
	private List<Integer> url;
	public NoticeLocalPagerAdapter(Context context, List<Integer> url) {
		this.context = context;
		this.url=url;
	};

	@Override
	public int getCount() {
		return url.size();
	}

	@Override
	public Object instantiateItem(View convertView, int position) {
		
		PicModelHodler  holder = new PicModelHodler();
		holder.imageView.setScaleType(ScaleType.FIT_XY);
		holder.imageView.setImageResource(url.get(position));
		((ViewPager) convertView).addView(holder.imageView);
		return holder.imageView;
	}

	@Override
	public void destroyItem(View arg0, int arg1, Object arg2) {
		ImageView image = (ImageView) arg2;
		image.setImageBitmap(null);
		((ViewPager) arg0).removeView(image);
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == arg1;
	}
	private final class PicModelHodler {
		public ImageView imageView = new ImageView(context);
	}

}